import Vue from 'vue'
import Router from 'vue-router'
import Layou from '@/components/Layou/Layou'
//导入store
import store from '../store/index'
Vue.use(Router)

export const routes = [

    // 注册
    {
        meta: {
            title: "卖座注册"
        },
        hidden: true,
        path: "/register",
        name: "register",
        component: () =>
            import ('@/page/register/register')
    },
    // 登录
    {
        meta: {
            title: "卖座登录"
        },
        hidden: true,
        path: "/",
        name: "logn",
        component: () =>
            import ('@/page/login/login')
    },
    //电影模块
    {
        meta: {
            title: "电影模块",
            icon: 'iconfont icon-dianying'
        },
        path: '/film',
        name: "film",
        component: Layou,
        children: [{
                meta: {
                    title: "电影添加",
                    icon: "iconfont icon-yingyuan3"
                },
                path: "add",
                name: "add",
                component: () =>
                    import ('@/page/film/children/filmAdd')
            },
            {
                hidden: true,
                meta: {
                    title: "电影编辑",
                    icon: "iconfont icon-yingyuan3"
                },
                path: "edit/:filmId",
                name: "adeditd",
                component: () =>
                    import ('@/page/film/children/filmEdit')
            },
            {
                meta: {
                    title: "电影列表",
                    icon: "iconfont icon-yingyuan3"
                },
                path: "list",
                name: "list",
                component: () =>
                    import ('@/page/film/children/filmList')
            },
        ]
    },
    //影院模块
    {
        meta: {
            title: "影院模块",
            icon: 'iconfont icon-dianying'
        },
        path: '/cinema',
        name: "cinema",
        component: Layou,
        children: [{
                meta: {
                    title: "影院列表",
                    icon: "iconfont icon-yingyuan3"
                },
                path: "list",
                name: "list",
                component: () =>
                    import ('@/page/cinema/children/cinemaList')
            },
            {
                meta: {
                    title: "添加影院",
                    icon: "iconfont icon-yingyuan2"
                },
                path: "add",
                name: "add",
                component: () =>
                    import ('@/page/cinema/children/cinemaAdd')
            },
            {
                hidden: true,
                meta: {
                    title: "编辑影院",
                    icon: "iconfont icon-yingyuan2"
                },
                path: "edit/:cinemaId",
                name: "edit",
                component: () =>
                    import ('@/page/cinema/children/edit')
            },
            {
                hidden: true,
                meta: {
                    title: "影院区域",
                    icon: "iconfont icon-yingyuan1"
                },
                path: "area",
                name: "area",
                component: () =>
                    import ('@/page/cinema/children/cinemaArea')
            },
        ]

    },
    {
        path: '/city',
        name: "city",
        component:
        // () => import ('@/page/city/index')
            Layou,

        //定义一个meta对象，用于存放信息
        meta: {
            title: "城市模块",
            icon: 'iconfont icon-chengshi'

        },
        children: [{
                // 城市列表信息
                meta: {
                    title: "城市列表",
                    icon: 'iconfont icon-a101'

                },
                path: 'list',
                name: "list",
                component: () =>
                    import ('@/page/city/children/list')
            }, {
                // 城市添加信息
                meta: {
                    title: "城市添加",
                    icon: 'iconfont icon-icon02'
                },
                path: 'add',
                name: "add",
                component: () =>
                    import ('@/page/city/children/merge')
            },
            {
                meta: {
                    title: "城市编辑",

                },
                hidden: true,
                path: "edit/:cityId",

                component: () =>
                    import ('@/page/city/children/merge')
            }
        ]
    },
    {
        path: '/area',
        name: "area",
        component:
        // () => import ('@/page/area/index')
            Layou,
        //区域模块
        meta: {
            title: "区域模块",
            icon: 'iconfont icon-quyuliebiao'
        },
        children: [{
                meta: {
                    title: "区域列表",
                    icon: 'iconfont icon-quyu-copy'
                },
                path: 'list',
                name: "list",
                component: () =>
                    import ('@/page/area/children/list')
            }, {
                meta: {
                    title: "区域添加",
                    icon: 'iconfont icon-icon02'
                },
                path: 'add',
                name: "add",
                component: () =>
                    import ('@/page/area/children/merge')
            },
            {
                hidden: true,
                meta: {
                    title: "区域编辑"
                },
                path: "edit/:areaId",

                component: () =>
                    import ('@/page/area/children/merge')
            }

        ]
    },
    {
        hidden: true,
        path: "/home",

        component: Layou,
        children: [{
            meta: {
                title: "首页",
            },
            hidden: true,
            path: "homeContent",
            component: () =>
                import ('@/page/home/home')

        }]
    },

    {
        meta: {
            title: "测试模块"
        },
        path: '/demo',
        name: "demo",
        component:
        // () => import ('@/page/area/index')
            Layou,
        children: [{
            meta: {
                title: "demo"
            },
            path: 'demo',
            name: "demo",
            component: () =>
                import ('@/demo/demo')
        }]
    }

]
let router = new Router({
    routes

})
router.beforeEach((to, from, next) => {
    console.log(to)
        // 修改网页标题
    document.title = to.meta.title;

    if (!store.state.isLogin && to.path != '/') {
        next('/')
    } else {
        next()
    }



    // next()
})

export default router